<?php
	class nhomhangdb
	{
		public function Add($TenNhomHang)
		{
			$sql = "INSERT INTO `tbl_nhomhang`(`TenNhomHang`) 
			VALUES ('$TenNhomHang')";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaNhomHang)
		{
			$sql = "DELETE FROM `tbl_nhomhang` WHERE `MaNhomHang` = '$MaNhomHang'";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaNhomHang, $TenNhomHang)
		{
			$sql = " UPDATE `tbl_nhomhang` SET `TenNhomHang` = '$TenNhomHang' WHERE `MaNhomHang` = $MaNhomHang "; 
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
	
		public function GetList($MaNhomHang, $TenNhomHang)
		{
			$sql = "SELECT * FROM `tbl_nhomhang` WHERE 1";
			if($MaNhomHang!="")
				$sql .= " AND `MaNhomHang` = '$MaNhomHang' ";
			if($TenNhomHang!="")
				$sql .= " AND `TenNhomHang` LIKE '%$TenNhomHang%' ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		public function Find( $TenNhomHang)
		{
			$sql = "SELECT * FROM `tbl_nhomhang` WHERE 1";
			if($TenNhomHang!="")
				$sql = " SELECT * FROM `tbl_nhomhang` WHERE `TenNhomHang` LIKE '%$TenNhomHang%' ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>